package operations;

import Book.*;

import java.util.Scanner;

//查找书籍
public class SearchOperation implements IOperation{
    public void work(BookList bookList){
        System.out.println("搜索书籍");
        System.out.println("请输入你要查找的书籍：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        int currentSize = bookList.getUsedsize();
        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getPos(i);
            if(name.equals(book.getName())){
                System.out.println("找到这本书，信息如下");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书");
    }
}
